package cn.chitanda.weather.data.network

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory

private const val key = "fdd88ed3893948f0a64a0b448702e73d"

object RetrofitCreator {

    private val builder = Retrofit.Builder()
        .baseUrl("https://free-api.heweather.net/")
        .client(OkHttpClient.Builder().build())
        .addConverterFactory(ScalarsConverterFactory.create())
        .addConverterFactory(GsonConverterFactory.create())

    private var retrofit = builder.build()

    fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass)

    private val builder1 = Retrofit.Builder()
        .baseUrl("https://search.heweather.net/")
        .client(OkHttpClient.Builder().build())
        .addConverterFactory(ScalarsConverterFactory.create())
        .addConverterFactory(GsonConverterFactory.create())

    private var retrofit1 = builder1.build()

    fun <T> create1(serviceClass: Class<T>): T = retrofit1.create(serviceClass)
}